class Solution:
    def convert(self, s: str, numRows: int) -> str:
        result = [['' for _ in range(len(s))] for _ in range(numRows)]
        direct = True # 真为下
        i = 0
        j = 0
        for t in s:
            result[i][j] = t
            if direct:
                i += 1
            else:
                i -= 1
                j += 1
            if i == 0 or i == numRows - 1: direct = not direct
        ans = []
        for i in range(numRows):
            for j in range(len(s)):
                ans.append(result[i][j])
        return ''.join(ans)

if __name__ == '__main__':

    s = Solution()
    r = s.convert(s = "AB", numRows = 1)
    print(r)